/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv3.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.taobao.ibatiside.model.mapperv3.Association;
import org.taobao.ibatiside.model.mapperv3.Case;
import org.taobao.ibatiside.model.mapperv3.Collection;
import org.taobao.ibatiside.model.mapperv3.Constructor;
import org.taobao.ibatiside.model.mapperv3.Discriminator;
import org.taobao.ibatiside.model.mapperv3.Id;
import org.taobao.ibatiside.model.mapperv3.Mapperv3Package;
import org.taobao.ibatiside.model.mapperv3.Result;
import org.taobao.ibatiside.model.mapperv3.ResultMap;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Case</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getConstructor <em>Constructor</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getIdx <em>Idx</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getResult <em>Result</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getAssociation <em>Association</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getCollection <em>Collection</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getDiscriminator <em>Discriminator</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getResultMap <em>Result Map</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getResultType <em>Result Type</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.CaseImpl#getValue <em>Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CaseImpl extends EObjectImpl implements Case {
	/**
	 * The cached value of the '{@link #getConstructor() <em>Constructor</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConstructor()
	 * @generated
	 * @ordered
	 */
	protected Constructor constructor;

	/**
	 * The cached value of the '{@link #getIdx() <em>Idx</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdx()
	 * @generated
	 * @ordered
	 */
	protected EList<Id> idx;

	/**
	 * The cached value of the '{@link #getResult() <em>Result</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResult()
	 * @generated
	 * @ordered
	 */
	protected EList<Result> result;

	/**
	 * The cached value of the '{@link #getAssociation() <em>Association</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAssociation()
	 * @generated
	 * @ordered
	 */
	protected EList<Association> association;

	/**
	 * The cached value of the '{@link #getCollection() <em>Collection</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCollection()
	 * @generated
	 * @ordered
	 */
	protected EList<Collection> collection;

	/**
	 * The cached value of the '{@link #getDiscriminator() <em>Discriminator</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDiscriminator()
	 * @generated
	 * @ordered
	 */
	protected Discriminator discriminator;

	/**
	 * The cached value of the '{@link #getResultMap() <em>Result Map</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResultMap()
	 * @generated
	 * @ordered
	 */
	protected ResultMap resultMap;

	/**
	 * The default value of the '{@link #getResultType() <em>Result Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResultType()
	 * @generated
	 * @ordered
	 */
	protected static final String RESULT_TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getResultType() <em>Result Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResultType()
	 * @generated
	 * @ordered
	 */
	protected String resultType = RESULT_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected static final String VALUE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected String value = VALUE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CaseImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv3Package.Literals.CASE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Constructor getConstructor() {
		return constructor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetConstructor(Constructor newConstructor, NotificationChain msgs) {
		Constructor oldConstructor = constructor;
		constructor = newConstructor;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Mapperv3Package.CASE__CONSTRUCTOR, oldConstructor, newConstructor);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConstructor(Constructor newConstructor) {
		if (newConstructor != constructor) {
			NotificationChain msgs = null;
			if (constructor != null)
				msgs = ((InternalEObject)constructor).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Mapperv3Package.CASE__CONSTRUCTOR, null, msgs);
			if (newConstructor != null)
				msgs = ((InternalEObject)newConstructor).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Mapperv3Package.CASE__CONSTRUCTOR, null, msgs);
			msgs = basicSetConstructor(newConstructor, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.CASE__CONSTRUCTOR, newConstructor, newConstructor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Id> getIdx() {
		if (idx == null) {
			idx = new EObjectContainmentEList<Id>(Id.class, this, Mapperv3Package.CASE__IDX);
		}
		return idx;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Result> getResult() {
		if (result == null) {
			result = new EObjectContainmentEList<Result>(Result.class, this, Mapperv3Package.CASE__RESULT);
		}
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Association> getAssociation() {
		if (association == null) {
			association = new EObjectContainmentEList<Association>(Association.class, this, Mapperv3Package.CASE__ASSOCIATION);
		}
		return association;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Collection> getCollection() {
		if (collection == null) {
			collection = new EObjectContainmentEList<Collection>(Collection.class, this, Mapperv3Package.CASE__COLLECTION);
		}
		return collection;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Discriminator getDiscriminator() {
		return discriminator;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDiscriminator(Discriminator newDiscriminator, NotificationChain msgs) {
		Discriminator oldDiscriminator = discriminator;
		discriminator = newDiscriminator;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Mapperv3Package.CASE__DISCRIMINATOR, oldDiscriminator, newDiscriminator);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDiscriminator(Discriminator newDiscriminator) {
		if (newDiscriminator != discriminator) {
			NotificationChain msgs = null;
			if (discriminator != null)
				msgs = ((InternalEObject)discriminator).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Mapperv3Package.CASE__DISCRIMINATOR, null, msgs);
			if (newDiscriminator != null)
				msgs = ((InternalEObject)newDiscriminator).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Mapperv3Package.CASE__DISCRIMINATOR, null, msgs);
			msgs = basicSetDiscriminator(newDiscriminator, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.CASE__DISCRIMINATOR, newDiscriminator, newDiscriminator));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ResultMap getResultMap() {
		return resultMap;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setResultMap(ResultMap newResultMap) {
		ResultMap oldResultMap = resultMap;
		resultMap = newResultMap;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.CASE__RESULT_MAP, oldResultMap, resultMap));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getResultType() {
		return resultType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setResultType(String newResultType) {
		String oldResultType = resultType;
		resultType = newResultType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.CASE__RESULT_TYPE, oldResultType, resultType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getValue() {
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValue(String newValue) {
		String oldValue = value;
		value = newValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.CASE__VALUE, oldValue, value));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Mapperv3Package.CASE__CONSTRUCTOR:
				return basicSetConstructor(null, msgs);
			case Mapperv3Package.CASE__IDX:
				return ((InternalEList<?>)getIdx()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.CASE__RESULT:
				return ((InternalEList<?>)getResult()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.CASE__ASSOCIATION:
				return ((InternalEList<?>)getAssociation()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.CASE__COLLECTION:
				return ((InternalEList<?>)getCollection()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.CASE__DISCRIMINATOR:
				return basicSetDiscriminator(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv3Package.CASE__CONSTRUCTOR:
				return getConstructor();
			case Mapperv3Package.CASE__IDX:
				return getIdx();
			case Mapperv3Package.CASE__RESULT:
				return getResult();
			case Mapperv3Package.CASE__ASSOCIATION:
				return getAssociation();
			case Mapperv3Package.CASE__COLLECTION:
				return getCollection();
			case Mapperv3Package.CASE__DISCRIMINATOR:
				return getDiscriminator();
			case Mapperv3Package.CASE__RESULT_MAP:
				return getResultMap();
			case Mapperv3Package.CASE__RESULT_TYPE:
				return getResultType();
			case Mapperv3Package.CASE__VALUE:
				return getValue();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv3Package.CASE__CONSTRUCTOR:
				setConstructor((Constructor)newValue);
				return;
			case Mapperv3Package.CASE__IDX:
				getIdx().clear();
				getIdx().addAll((java.util.Collection<? extends Id>)newValue);
				return;
			case Mapperv3Package.CASE__RESULT:
				getResult().clear();
				getResult().addAll((java.util.Collection<? extends Result>)newValue);
				return;
			case Mapperv3Package.CASE__ASSOCIATION:
				getAssociation().clear();
				getAssociation().addAll((java.util.Collection<? extends Association>)newValue);
				return;
			case Mapperv3Package.CASE__COLLECTION:
				getCollection().clear();
				getCollection().addAll((java.util.Collection<? extends Collection>)newValue);
				return;
			case Mapperv3Package.CASE__DISCRIMINATOR:
				setDiscriminator((Discriminator)newValue);
				return;
			case Mapperv3Package.CASE__RESULT_MAP:
				setResultMap((ResultMap)newValue);
				return;
			case Mapperv3Package.CASE__RESULT_TYPE:
				setResultType((String)newValue);
				return;
			case Mapperv3Package.CASE__VALUE:
				setValue((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv3Package.CASE__CONSTRUCTOR:
				setConstructor((Constructor)null);
				return;
			case Mapperv3Package.CASE__IDX:
				getIdx().clear();
				return;
			case Mapperv3Package.CASE__RESULT:
				getResult().clear();
				return;
			case Mapperv3Package.CASE__ASSOCIATION:
				getAssociation().clear();
				return;
			case Mapperv3Package.CASE__COLLECTION:
				getCollection().clear();
				return;
			case Mapperv3Package.CASE__DISCRIMINATOR:
				setDiscriminator((Discriminator)null);
				return;
			case Mapperv3Package.CASE__RESULT_MAP:
				setResultMap((ResultMap)null);
				return;
			case Mapperv3Package.CASE__RESULT_TYPE:
				setResultType(RESULT_TYPE_EDEFAULT);
				return;
			case Mapperv3Package.CASE__VALUE:
				setValue(VALUE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv3Package.CASE__CONSTRUCTOR:
				return constructor != null;
			case Mapperv3Package.CASE__IDX:
				return idx != null && !idx.isEmpty();
			case Mapperv3Package.CASE__RESULT:
				return result != null && !result.isEmpty();
			case Mapperv3Package.CASE__ASSOCIATION:
				return association != null && !association.isEmpty();
			case Mapperv3Package.CASE__COLLECTION:
				return collection != null && !collection.isEmpty();
			case Mapperv3Package.CASE__DISCRIMINATOR:
				return discriminator != null;
			case Mapperv3Package.CASE__RESULT_MAP:
				return resultMap != null;
			case Mapperv3Package.CASE__RESULT_TYPE:
				return RESULT_TYPE_EDEFAULT == null ? resultType != null : !RESULT_TYPE_EDEFAULT.equals(resultType);
			case Mapperv3Package.CASE__VALUE:
				return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (resultType: ");
		result.append(resultType);
		result.append(", value: ");
		result.append(value);
		result.append(')');
		return result.toString();
	}

} //CaseImpl
